<template>
  <view class="main">
    <!-- 顶部 -->
    <!-- <view class="top" :style="{opacity:topOpacity}" v-if="!scrollTop"> -->
    <!-- <view class="top" :style="{opacity:topOpacity}" > -->
    <view class="top" :class="[{ top1: preview }]">
      <image
        class="bg"
        src="../../images/circle/background.png"
        mode="scaleToFill"
      ></image>
      <!-- 顶部操作 -->
      <view :class="[{ 'top-padding': preview }, 'top-head']">
        <view class="back" @tap="handleFan">
          <image src="../../images/circle/back.png" mode="heightFix"></image>
        </view>
        <text class="top-head-t" v-show="preview" style="color: #ffffff"
          >圈子介绍</text
        >
        <view v-if="type == 2" style="width: 180rpx"> </view>
        <navigator
          :url="'/pages/index/chargeManage?id=' + id"
          hover-class="none"
          v-if="type != 2"
        >
          <view class="manage">
            <image
              src="../../images/circleIntro/manage.png"
              mode="widthFix"
            ></image>
            <text>管理后台</text>
          </view>
        </navigator>
      </view>
      <view class="top-info" v-show="!preview">
        <image
          class="top-info-avatar"
          :src="
            detail.orgUrl
              ? detail.orgUrl
              : 'https://img.yiqilaiwang.com/20201224104019.png'
          "
          mode="mode"
        ></image>
        <view class="top-info-right">
          <h3>{{ detail.orgName }}</h3>
          <text class="text">发起人：{{ detail.applyName }}</text>
          <view class="tag">
            <view
              style="display: flex; flex-wrap: wrap"
              v-show="detail && detail.friendsLists.length"
            >
              <text v-for="(tag, index) in detail.friendsLists" :key="index">{{
                tag
              }}</text>
            </view>
            <view class="" v-show="detail && !detail.friendsLists.length">
              <text>其他</text>
            </view>
          </view>
        </view>
      </view>
    </view>
    <!-- 吸顶 -->
    <!-- 	<view class="top1" :style="{opacity:topOpacity2}" v-if="scrollTop || !preview">
			123
		</view> -->
    <view :class="[preview ? 'content content1' : 'content']">
      <!-- <view :class="[scrollTop == true ? 'content content6' : 'content']"> -->
      <!-- 圈子介绍 -->
      <!-- <view :class="[scrollTop == true ? 'intro active999' : 'intro']" v-show="!preview"> -->
      <view v-show="!preview" class="intro">
        <text class="intro-title">圈子介绍</text>
        <!-- <text class="intro-view" @tap="preview = true">预览</text> -->
        <navigator :url="'/pages/circle/circlePreview?id=' + id">
          <text class="intro-view">预览</text>
        </navigator>
      </view>
      <view class="line" v-show="!preview"></view>
      <view
        class="intro-content"
        :style="{
          color:
            !detail.circlePromotion ||
            detail.circlePromotion == circlePromotionDefault
              ? '#999999'
              : '#111111',
        }"
        v-html="
          detail.circlePromotion
            ? detail.circlePromotion
            : detail && !detail.circlePromotion
            ? circlePromotionDefault
            : ''
        "
      ></view>
    </view>
    <!-- 编辑 -->
    <view class="bottom" v-show="!preview">
      <view class="edit" @tap="toPage">编辑</view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      topOpacity: 1,
      scrollTop: false, //判断滚动
      topOpacity2: 0,
      id: "",
      detail: "",
      preview: false,
      type: 0,
      circlePromotionDefault: `<p>欢迎来到商界精英圈子，在这里你可以：</p><p><br></p><p>1、抢先知晓商界精英智慧，大量结交商界精英人脉</p><p><br></p><p>2、与各位老板在圈子内交流互动、共同进步</p><p><br></p><p>3、打造良心商业生态，撮合生意，实现互利共赢</p>`,
    };
  },
  onShow() {
    this.qzData();
  },
  onLoad(option) {
    this.id = option.id;
    this.type = option.type;
  },
  methods: {
    toPage() {
      var content = this.detail.circlePromotion
        ? this.detail.circlePromotion
        : this.circlePromotionDefault;
      uni.setStorageSync("text", content);
      uni.navigateTo({
        // url: "/pages/circle/editor?id=" + this.id + '&content=' + encodeURIComponent(JSON.stringify(this.detail.circlePromotion)),
        url: "/pages/circle/editorFile?id=" + this.id,
      });
    },
    chooseFile() {
      uni.chooseFile({
        count: 10,
        type: "image",
        success(res) {
          // tempFilePath可以作为img标签的src属性显示图片
          // const tempFilePaths = res.tempFiles;
          // console.log(tempFilePaths);
        },
      });
    },
    // 返回
    handleFan() {
      if (this.preview) {
        this.preview = false;
      } else {
        window.history.go(-1);
      }
    },
    // 圈子基本信息
    qzData() {
      let token = uni.getStorageSync("token");
      const that = this;
      this.request({
        url: "h5/orgCircle/friendsHomeInfo",
        method: "POST",
        header: {
          "content-type": "application/json;charset=UTF-8",
          "api-client": "72e0fee8172411ea995200163e05ff66",
          "api-version": this.globalData.apiVersion,
          "Source-Type": 7,
          token: token,
        },
        data: {
          orgId: this.id,
        },
      }).then((res) => {
        if (res.data.code == 200) {
          that.detail = res.data.data;
        }
      });
    },
  },
  onPageScroll(e) {
    let _sTop = 155;
    let _top = e.scrollTop;
    this.topOpacity = Math.abs(_sTop - e.scrollTop) / _sTop;
    this.topOpacity2 = Math.abs(1 - this.topOpacity);
    if (_top >= 100) {
      this.scrollTop = true;
      this.topOpacity2 = 1;
    } else if (_top <= 20) {
      this.scrollTop = false;
      this.topOpacity2 = Math.abs(_sTop - e.scrollTop) / 150;
    }
  },
};
</script>

<style lang="less" scoped>
.main {
  .content6 {
    margin-top: 200rpx;
  }
  .top.top1 {
    height: auto;
  }
  .top {
    width: 100%;
    position: fixed;
    top: 0;
    z-index: 10;
    height: 380rpx;
    .bg {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      width: 100%;
      height: 100%;
      z-index: -1;
    }
    .top-padding.top-head {
      padding: 37rpx 22rpx 37rpx 31rpx;
    }
    .top-head {
      display: flex;
      justify-content: space-between;
      padding: 37rpx 22rpx 76rpx 31rpx;
      .back {
        height: 40rpx;
        width: 180rpx;
        image {
          width: auto;
          height: 100%;
        }
      }
      .manage {
        display: flex;
        align-items: center;
        width: 180rpx;
        justify-content: flex-end;
        image {
          width: 38rpx;
          margin-right: 11rpx;
        }
        text {
          font-size: 28rpx;
          font-family: PingFangSC, PingFangSC-Medium;
          font-weight: 500;
          text-align: left;
          color: #ffffff;
          line-height: 40rpx;
        }
      }
    }
    .top-info {
      display: flex;
      padding: 0 36rpx 0rpx;
      .top-info-avatar {
        width: 148rpx;
        min-width: 148rpx;
        height: 148rpx;
        max-height: 148rpx;
        margin-right: 30rpx;
        border-radius: 12rpx;
        box-shadow: 0px 18rpx 18rpx -12rpx rgba(17, 17, 17, 0.15);
      }
      .top-info-right {
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        color: #ffffff;
        flex: 1;
        .text {
          font-size: 24rpx;
          line-height: 33rpx;
        }
        h3 {
          font-size: 44rpx;
          font-weight: 500;
          line-height: 62rpx;
          margin-bottom: 6rpx;
        }
        .tag {
          display: flex;
          flex-wrap: wrap;
          overflow: hidden;
          margin-top: 19rpx;
          height: 36rpx;
          text {
            display: flex;
            padding: 3rpx 8rpx;
            background: rgba(240, 247, 255, 0.14);
            border-radius: 8rpx;
            font-size: 24rpx;
            font-family: PingFangSC, PingFangSC-Regular;
            font-weight: 400;
            text-align: left;
            color: #ffffff;
            line-height: 33rpx;
            margin-right: 12rpx;
          }
        }
      }
    }
  }
  .active999 {
    background-color: #fff;
    width: 100%;
    position: fixed;
    top: 116rpx;
    left: 0;
    z-index: 999;
    // height: 75rpx;
  }
  .content.content1 {
    top: 90rpx;
  }
  .content {
    top: 478rpx;

    position: absolute;
    left: 0;
    right: 0;
    .intro {
      display: flex;
      justify-content: space-between;
      align-items: center;
      position: fixed;
      top: 368rpx;
      left: 0rpx;
      right: 0rpx;
      padding: 32rpx 6rpx 18rpx;
      border-bottom: 1px solid #dddddd;
      background: #fff;
      margin: 0 30rpx;
      .intro-title {
        font-size: 36rpx;
        font-family: PingFangSC, PingFangSC-Semibold;
        font-weight: 600;
        color: #111111;
      }
      .intro-view {
        font-size: 28rpx;
        font-family: PingFangSC, PingFangSC-Medium;
        font-weight: 500;
        color: #0f6ede;
        padding: 10rpx;
        margin-right: -10rpx;
      }
    }
    // .line{
    // 	width: calc(100% - 72rpx);
    // 	height: 1px;
    // 	background:#dddddd;
    // 	margin:18rpx 0 30rpx;
    // 	position:fixed;
    // 	top:448rpx;
    // 	left:36rpx;
    // 	right:36rpx;
    // }
    .intro-content {
      padding: 37rpx 36rpx 200rpx;
      font-size: 34rpx;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      color: #111111;
      line-height: 48rpx;
      white-space: pre-wrap;
      letter-spacing: 0.06rem;
      /deep/ img {
        width: 100%;
        max-width: 100%;
        height: auto;
      }
      /deep/ video {
        width: 100%;
        max-width: 100%;
      }
      /deep/ blockquote {
        border-left: 2px solid #ccc;
        margin-left: 1.5rem;
        padding-left: 1rem;
      }
      /deep/ .right {
        display: none;
      }
      /deep/ * {
        font-size: 34rpx !important;
        line-height: 48rpx !important;
        font-family: PingFangSC, PingFangSC-Regular !important;
        // text-align: justify !important;
        font-weight: 400 !important;
      }
      /deep/ .text {
        width: calc(100% - 44px);
        font-family: PingFangSC, PingFangSC-Regular;
        font-weight: 400;
        color: rgb(17, 17, 17);
        overflow: hidden;
        text-overflow: ellipsis;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        display: -webkit-box;
        line-height: 24px !important;
        font-size: 15px !important;
        word-break: break-all;
      }
    }
  }
  .bottom {
    position: fixed;
    background: #ffffff;
    bottom: 0;
    border-top: 1px solid #dddddd;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 10rpx 25rpx 78rpx;
    width: 100%;
    box-sizing: border-box;
    .edit {
      border-radius: 8rpx;
      width: 100%;
      height: 80rpx;
      line-height: 80rpx;
      text-align: center;
      background: #0f6ede;
      font-size: 30rpx;
      font-family: PingFangSC, PingFangSC-Regular;
      font-weight: 400;
      text-align: center;
      color: #ffffff;
    }
  }
}
</style>
